package lion.framework.core.task.anno;

import java.lang.annotation.Annotation;

import org.apache.commons.lang.StringUtils;

import lion.dev.lang.MapJ;
import lion.framework.core.anno.AnnotationProcessorManager;
import lion.framework.core.anno.IAnnotationProcessor;
import lion.framework.core.bean.BeanFactory;
import lion.framework.core.task.builder.IScheduleBuilder;
import lion.framework.core.task.builder.ScheduleBuilderManager;

/**
 * @author lion
 * @email hl_0074@sina.com
 * @date 2015年8月6日
 */
// @AnnoProcessor(ScheduleBuilder.class)
public class ScheduleBuilderAnnoProcessor implements IAnnotationProcessor {

	@Override
	public void processe(MapJ ctx, Annotation anno) throws Exception {

		Class<? extends IScheduleBuilder> clazz = ctx.getE(AnnotationProcessorManager.ANNO_CONTEXT_TARGET);

		ScheduleBuilder sb = (ScheduleBuilder) anno;
		if (StringUtils.isBlank(sb.value())) { return; }

		ScheduleBuilderManager.add(sb.value(), BeanFactory.create(clazz));
	}
}
